package com.sihai.ehr.model.biz;

import com.sihai.core.BaseEntity;
import com.sihai.ehr.model.sys.AuditStatus;
import com.sihai.ehr.model.sys.Organization;

import javax.persistence.*;
import java.util.Date;

/**
 * author: wxn
 * since: 13-4-8 下午9:07
 * 员工异动实体类
 */
@Entity
public class Transaction  extends BaseEntity<Long> {
    public static enum TransactionType{
        organization("部门异动"),
        promotion("晋升异动"),
        demotion("降职异动");

        private TransactionType(String name) {
            this.name = name;
        }
        private String name;
        public String getName() {
            return this.name;
        }
    }

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "employeeinfo_work_id")
    private EmployeeinfoWork work;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "old_organization_id")
    private Organization oldOrganization; /* 异动前的部门 */

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "old_duty_id")
    private Duty oldDuty; //异动前的职务

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "old_grade_id")
    private Grade oldGrade;//异动前的职等

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "old_grade_level_id")
    private Grade oldGradeLevel;//异动前的职级

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "new_organization_id")
    private Organization newOrganization; /* 异动后的部门 */

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "new_duty_id")
    private Duty newDuty; //异动后的职务

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "new_grade_id")
    private Grade newGrade;//异动后的职等

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "new_grade_level_id")
    private Grade newGradeLevel;//异动后的职级

    private Date moveDateTiem; //异动时间

    @Enumerated(EnumType.STRING)
    private AuditStatus status; /* 审核状态 */

    @Enumerated(EnumType.STRING)
    private TransactionType type; /* 异动类型 */

    private boolean finish; //是否异动完成

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "top_organization_id")
    private Organization topOrganization; //所属公公司

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public EmployeeinfoWork getWork() {
        return work;
    }

    public void setWork(EmployeeinfoWork work) {
        this.work = work;
    }

    public Organization getOldOrganization() {
        return oldOrganization;
    }

    public void setOldOrganization(Organization oldOrganization) {
        this.oldOrganization = oldOrganization;
    }

    public Duty getOldDuty() {
        return oldDuty;
    }

    public void setOldDuty(Duty oldDuty) {
        this.oldDuty = oldDuty;
    }

    public Grade getOldGrade() {
        return oldGrade;
    }

    public void setOldGrade(Grade oldGrade) {
        this.oldGrade = oldGrade;
    }

    public Grade getOldGradeLevel() {
        return oldGradeLevel;
    }

    public void setOldGradeLevel(Grade oldGradeLevel) {
        this.oldGradeLevel = oldGradeLevel;
    }

    public Organization getNewOrganization() {
        return newOrganization;
    }

    public void setNewOrganization(Organization newOrganization) {
        this.newOrganization = newOrganization;
    }

    public Duty getNewDuty() {
        return newDuty;
    }

    public void setNewDuty(Duty newDuty) {
        this.newDuty = newDuty;
    }

    public Grade getNewGrade() {
        return newGrade;
    }

    public void setNewGrade(Grade newGrade) {
        this.newGrade = newGrade;
    }

    public Grade getNewGradeLevel() {
        return newGradeLevel;
    }

    public void setNewGradeLevel(Grade newGradeLevel) {
        this.newGradeLevel = newGradeLevel;
    }

    public Date getMoveDateTiem() {
        return moveDateTiem;
    }

    public void setMoveDateTiem(Date moveDateTiem) {
        this.moveDateTiem = moveDateTiem;
    }

    public AuditStatus getStatus() {
        return status;
    }

    public void setStatus(AuditStatus status) {
        this.status = status;
    }

    public TransactionType getType() {
        return type;
    }

    public void setType(TransactionType type) {
        this.type = type;
    }

    public boolean isFinish() {
        return finish;
    }

    public void setFinish(boolean finish) {
        this.finish = finish;
    }

    public Organization getTopOrganization() {
        return topOrganization;
    }

    public void setTopOrganization(Organization topOrganization) {
        this.topOrganization = topOrganization;
    }
}
